package com.youxin.cpcenter.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Service;

import com.youxin.busfoundation.bean.BaseRequestBean;
import com.youxin.busfoundation.bean.ResponseObject;
import com.youxin.busfoundation.bean.staticalchart.RequestStaticalOverviewBean;
import com.youxin.busfoundation.bean.staticalchart.ResponseStaticalChartBean;
import com.youxin.busfoundation.bean.staticalchart.ResponseStaticalOverviewBean;
import com.youxin.cpcenter.service.AdminIndexService;

import net.sf.json.JSONArray;

/**
 * @ClassName: AdminIndexServiceImpl 
 * @Description: 后台首页 
 * @author yingde.cao
 * @date 2017年12月21日 上午11:13:41 
 *
 */
@Service("adminIndexService")
public class AdminIndexServiceImpl extends BaseServiceImpl implements AdminIndexService{	
	/**
	 * 首页数据总览
	 */
	public ResponseObject getDataStatisticalOverview(RequestStaticalOverviewBean bean) {
		
		ResponseStaticalOverviewBean overview = new ResponseStaticalOverviewBean();
		try {
			overview.setCoverage_citys_nums(34);
			overview.setCoverage_industry_nums(20);
			overview.setCoverage_ent_nums(105349602);
		} catch (Exception e) {
			logger.error("getDataStatisticalOverview 异常:", e);
		}
		//前端特殊要求（解析方便），此处封装成list
		List<ResponseStaticalOverviewBean> list = new ArrayList<ResponseStaticalOverviewBean>();
		list.add(overview);
		bean.setStaticalOverview(list);
		return ResponseObject.successObject(bean);
	}
	/**
	 * 首页图表统计城市数据
	 */
	@SuppressWarnings("unchecked")
	public ResponseObject getCitysStatisticalChart(BaseRequestBean bean) {		
		String json = null;
		List<ResponseStaticalChartBean>  chartList = new ArrayList<ResponseStaticalChartBean>();
		try {
		/*	chartList.setCode("11");
			chartList.setName("北京");
			chartList.setNumber(1136);*/
			json = "[{\"code\":\"11\",\"name\":\"北京市\",\"number\":1579321},{\"code\":\"12\",\"name\":\"天津市\",\"number\":1579312},{\"code\":\"13\",\"name\":\"河北省\",\"number\":1317221},{\"code\":\"14\",\"name\":\"山西省\",\"number\":691701},{\"code\":\"15\",\"name\":\"内蒙古自治区\",\"number\":528302},{\"code\":\"21\",\"name\":\"辽宁省\",\"number\":1297210},{\"code\":\"22\",\"name\":\"吉林省\",\"number\":602621},{\"code\":\"23\",\"name\":\"黑龙江省\",\"number\":618613},{\"code\":\"31\",\"name\":\"上海市\",\"number\":2418804},{\"code\":\"32\",\"name\":\"江苏省\",\"number\":3269504},{\"code\":\"33\",\"name\":\"浙江省\",\"number\":2406205},{\"code\":\"34\",\"name\":\"安徽省\",\"number\":1123807},{\"code\":\"35\",\"name\":\"福建省\",\"number\":1198308},{\"code\":\"36\",\"name\":\"江西省\",\"number\":679409},{\"code\":\"37\",\"name\":\"山东省\",\"number\":2563710},{\"code\":\"41\",\"name\":\"河南省\",\"number\":1624601},{\"code\":\"42\",\"name\":\"湖北省\",\"number\":1461502},{\"code\":\"43\",\"name\":\"湖南省\",\"number\":960034},{\"code\":\"44\",\"name\":\"广东省\",\"number\":4139346},{\"code\":\"45\",\"name\":\"广西壮族自治区\",\"number\":887267},{\"code\":\"46\",\"name\":\"海南省\",\"number\":301322},{\"code\":\"50\",\"name\":\"重庆市\",\"number\":785013},{\"code\":\"51\",\"name\":\"四川省\",\"number\":1762414},{\"code\":\"52\",\"name\":\"贵州省\",\"number\":518464},{\"code\":\"53\",\"name\":\"云南省\",\"number\":404401},{\"code\":\"54\",\"name\":\"西藏自治区\",\"number\":36103},{\"code\":\"61\",\"name\":\"陕西省\",\"number\":853105},{\"code\":\"62\",\"name\":\"甘肃省\",\"number\":112032},{\"code\":\"63\",\"name\":\"青海省\",\"number\":112013},{\"code\":\"64\",\"name\":\"宁夏回族自治区\",\"number\":157905},{\"code\":\"65\",\"name\":\"新疆维吾尔自治区\",\"number\":304701},{\"code\":\"71\",\"name\":\"台湾省\",\"number\":0},{\"code\":\"81\",\"name\":\"香港特别行政区\",\"number\":0},{\"code\":\"82\",\"name\":\"澳门特别行政区\",\"number\":0}]";
			JSONArray jsonarray = JSONArray.fromObject(json);
			chartList = (List<ResponseStaticalChartBean>)JSONArray.toCollection(jsonarray, ResponseStaticalChartBean.class);
		} catch (Exception e) {
			logger.error("getCitysStatisticalChart 异常:", e);
		}
		return ResponseObject.successObject(chartList);
	}
	/**
	 * 行业统计图表
	 */
	@SuppressWarnings("unchecked")
	public ResponseObject getIndustryStatisticalChart(BaseRequestBean bean) {
		String json = null;
		List<ResponseStaticalChartBean>  chartList = new ArrayList<ResponseStaticalChartBean>();
		try {
			json = "[{\"code\":\"A\",\"name\":\"农、林、牧、渔业\",\"number\":2481301},{\"code\":\"B\",\"name\":\"采矿业\",\"number\":199707},{\"code\":\"C\",\"name\":\"制造业\",\"number\":5940524},{\"code\":\"D\",\"name\":\"电力、燃气及水的生产和供应业\",\"number\":175803},{\"code\":\"E\",\"name\":\"建筑业\",\"number\":1704910},{\"code\":\"F\",\"name\":\"交通运输、仓储和邮政业\",\"number\":996938},{\"code\":\"G\",\"name\":\"信息传输、计算机服务和软件业\",\"number\":141803},{\"code\":\"H\",\"name\":\"批发和零售业\",\"number\":126507},{\"code\":\"I\",\"name\":\"住宿和餐饮业\",\"number\":802121},{\"code\":\"J\",\"name\":\"金融业\",\"number\":709938},{\"code\":\"K\",\"name\":\"房地产业\",\"number\":998232},{\"code\":\"L\",\"name\":\"租赁和商务服务业\",\"number\":3714378},{\"code\":\"M\",\"name\":\"科学研究、技术服务和地质勘查业\",\"number\":1768956},{\"code\":\"N\",\"name\":\"水利、环境和公共设施管理业\",\"number\":135524},{\"code\":\"O\",\"name\":\"居民服务和其他服务业\",\"number\":102954},{\"code\":\"P\",\"name\":\"教育\",\"number\":74978},{\"code\":\"Q\",\"name\":\"卫生、社会保障和社会福利业\",\"number\":48665},{\"code\":\"R\",\"name\":\"文化、体育和娱乐业\",\"number\":545843},{\"code\":\"S\",\"name\":\"公共管理和社会组织\",\"number\":34123},{\"code\":\"T\",\"name\":\"国际组织\",\"number\":46901}]";
			JSONArray jsonarray = JSONArray.fromObject(json);
			chartList = (List<ResponseStaticalChartBean>)JSONArray.toCollection(jsonarray, ResponseStaticalChartBean.class);
		} catch (Exception e) {
			logger.error("getIndustryStatisticalChart 异常:", e);
		}
		return ResponseObject.successObject(chartList);
	}
}
